﻿
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Gift.Model;
using Gift.DAL;
using System.Data;
using Gift.Model.ENUM;

    public partial class admin_order_OrderComplain : BaseAdmin
    {
        readonly DALOrderCompain theOrderCompain = new DALOrderCompain();
        readonly DALCompain theCompain = new DALCompain();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                base.ValidateLoginRule(ERule.CompainList);
                this.BindCompainTypeList();
                this.BindComainList();
            }
        }

        void BindCompainTypeList()
        {
            DataSet ds;
            ds = theCompain.GetList("");
            if (ds != null && ds.Tables.Count > 0)
            {
                this.ddlCompainType.DataTextField = "CompainName";
                this.ddlCompainType.DataValueField = "CompainId";
                this.ddlCompainType.DataSource = ds.Tables[0].DefaultView;
                this.ddlCompainType.DataBind();
                this.ddlCompainType.Items.Insert(0,new ListItem("投诉类别...", "0"));
            }
        }

        void BindComainList()
        {
            DataSet ds;
            ds = theOrderCompain.GetOrderCompainList(ordercode.Value.Trim(), int.Parse(this.ddlCompainType.SelectedItem.Value), int.Parse(this.ddlProcessType.SelectedItem.Value));
            if (ds != null && ds.Tables.Count > 0)
            {
                this.GridView1.DataSource = ds.Tables[0].DefaultView;
                this.GridView1.DataBind();
            }
        }

        protected void ibtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            this.BindComainList();
        }

        protected void PagerButtonClick(object sender, EventArgs e)
        {
            this.GridView1.PageIndex = Convert.ToInt32(((LinkButton)sender).CommandName) - 1;
            this.BindComainList();
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.GridView1.PageIndex = this.ddlCurrentPage.SelectedIndex;
            this.BindComainList();
        }
    }
